package lab01;

/**
 * Created by Administrator on 2017/12/17.
 */
public class Test05_1 {
    public static void main(String[] args) {
        int n = 100;
        System.out.println(sum1(n));
        System.out.println(sum2(n));
        System.out.println(sum3(n));
    }

    public static int sum1(int n) {
        int sum= 0;
        for (int i = 1; i <= n; i++) {
            sum = sum + i;
        }
        return sum;
    }
    public static int sum2(int n){
        int i=1;
        int sum=0;
        while (i<=100){
            sum=sum+i;
            i++;
        }return sum;

    }
    public static int sum3(int n){
        int i=1;
        int sum=0;
        do {sum=sum+i;i++;
        }
        while (i<=n);
        return sum;
        }
    }


